package fr.afcepf.iziticket.beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import fr.afcepf.iziticket.services.MonCompteService;

@ManagedBean(name="mbMonCompte")
@SessionScoped
public class MonCompteManagedBean{

	@ManagedProperty(value="#{mbLogin}")
	private LoginManagedBean mbLogin;
	
	private String aMdp;
	private String nMdp;
	private String n2Mdp;
	private String mail2;
	private String mail;
	
	private MonCompteService service = MonCompteService.getService();
	
	public MonCompteManagedBean() {
	}

	public String getMail() {
		this.mail=mbLogin.getUtilisateur().getMail();
		return mail;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public LoginManagedBean getMbLogin() {
		return mbLogin;
	}
	public void setMbLogin(LoginManagedBean mbLogin) {
		this.mbLogin = mbLogin;
	}
	public String getaMdp() {
		return aMdp;
	}
	public void setaMdp(String aMdp) {
		this.aMdp = aMdp;
	}
	public String getnMdp() {
		return nMdp;
	}
	public void setnMdp(String nMdp) {
		this.nMdp = nMdp;
	}
	public String getN2Mdp() {
		return n2Mdp;
	}
	public void setN2Mdp(String n2Mdp) {
		this.n2Mdp = n2Mdp;
	}
	public String getMail2() {
		return mail2;
	}
	public void setMail2(String mail2) {
		this.mail2 = mail2;
	}
	
	public String change(){
		
		service.change(mbLogin.getUtilisateur(), aMdp, nMdp, n2Mdp, mail, mail2);
		
		this.mail2="";
		this.aMdp="";
		this.nMdp="";
		this.n2Mdp="";
		
		return "";
	}
	
}
